package JZOffer;

import java.util.Stack;

public class _12 {
    class Solution {
        public void reOrderArray2(int[] array) {
            Stack<Integer> res = new Stack<Integer>();
            int oddCount = 0;
            int one = 1;
            for (int i = 0; i < array.length; i++) {
                if ((array[i]&one) != 0) res.push(array[i]);
                oddCount = i;
            }
            for (int i = 0; i < array.length; i++) {
                if ((array[i]&one)==0) res.push(array[i]);
            }
            for (int i = array.length - 1; i >= 0; i--) {
                array[i] = res.pop();
            }
        }
    }

    Solution getSolution() {
        return new Solution();
    }

    public static void main(String args[]) {
        _12 c = new _12();
        _12.Solution s = c.getSolution();
        int[] array = {1,2,3,4,5,6,7};
        s.reOrderArray2(array);
        for (int ii :
                array) {
            System.out.println(ii);
        }
    }
}
